<template>
  <!-- 卡片布局 -->
  <el-card class="box-card">
    <div slot="header" class="clearfix">
      <span>AI视频模板</span>
    </div>
    <!-- 按钮占位 -->
    <div>
      <el-row>
        <el-button plain size="mini">朴素按钮</el-button>
        <el-button type="primary" plain size="mini">主要按钮</el-button>
      </el-row>
    </div>

    <div style="height: 1000px">
      <div class="dakuang">
        <div class="xiaokuang" @mouseover="showFn" @mouseout="sshowFn">
          <div v-if="isshow">
            <img :src="list[0].cover_img" alt="" class="images" />
            <div class="title">
              <span class="p">{{ list[0].name }}</span><br>
              <span class="span1"> 2132132</span> <span class="span2">精品</span>
              <i></i>
            </div>
          </div>
          <div v-else>
            <video :src="list[0].href" class="videos" autoplay></video>
            <div class="bottons">
                <el-button type="primary" round>主要按钮</el-button>
            </div>
          </div>
        </div>
      </div>
    </div>
  </el-card>
</template>

<script>
export default {
  name: "Aivideo",
  data() {
    return {
      list: [],
      data: { page: 1, page_size: 20 },
      token: "",
      isshow: 1,
    };
  },
  async created() {
    this.getdata();
  },
  methods: {
    showFn() {
      this.isshow = 0;
      this.getdata();
    },
    sshowFn() {
      this.isshow = 1;
      this.getdata();
    },
    async getdata() {
      let ress = await this.$api.addtoken();
      this.token = ress.data.token;

      await this.$http
        .post(
          `http://media.api.appletcloud.net/api/ice/getTemplates?token=${this.token}`,
          {
            emulateJSON: true,
          }
        )
        .then((res) => {
          // console.log(res.data);
          this.list = res.data.data.list;
          // console.log(this.list[0]);
          console.log(this.list);
        });
    },
  },
};
</script>

<style scoped>
.p{
  margin-left: 30px;
}
.videos {
  height: 610px;
  width: 370px;
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  right: 0;
  padding: 20px;
}
.images {
  height: 600px;
  width: 350px;
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  right: 0;
  padding: 20px;
  margin-left: 5px;
}
.dakuang {
  height: 700px;
  width: 380px;
  position: relative;
  left: 0;
  top: 0;
  bottom: 0;
  right: 0;
}
.xiaokuang {
  height: 700px;
  width: 366px;
  /* padding: 20px; */
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  right: 0;
}
.title {
  position: absolute;
  bottom: 30px;
  font-size: 14px;
}
.bottons{
  position: absolute;
  bottom: 25px;
left: 35%;
}
.span1{
  margin-left: 80px;
  margin-right: 5px;
}
</style>
